import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class LineCounter {

    public static void main(String[] args) {
        long count = 0;
        long countNonEmpty = 0;

        List<File> list = new ArrayList<File>();
        list.add(new File("./src"));
        while (!list.isEmpty()) {
            File f = list.remove(0);
            if (f.isDirectory()) {
                list.addAll(Arrays.asList(f.listFiles()));
            } else if (f.getName().endsWith(".java")) {
                count += count(f);
                countNonEmpty += countNonEmpty(f);
            }
        }

        System.out.println("Total = \t" + count);
        System.out.println("Non-Empty = \t" + countNonEmpty);
    }

    private static long count(File f) {
        long ret = 0;
        try {
            BufferedReader br = new BufferedReader(new FileReader(f));
            for (String line = br.readLine(); line != null; line = br
                    .readLine()) {
                ret++;
            }
            br.close();
        } catch (Exception e) {

        }
        return ret;
    }

    private static long countNonEmpty(File f) {
        long ret = 0;
        try {
            BufferedReader br = new BufferedReader(new FileReader(f));
            for (String line = br.readLine(); line != null; line = br
                    .readLine()) {
                if (!line.trim().isEmpty()) {
                    ret++;
                }
            }
            br.close();
        } catch (Exception e) {

        }
        return ret;
    }

}
